package com.jungle.sp.daily.feature.d6_sequenced_collection;

import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.SequencedSet;
import java.util.TreeSet;

/**
 * @author Jungle
 * @create 2024-07-14 7:56
 */
public class Demo2 {
    public static void main(String[] args) {
        SequencedSet<String> set1 = new LinkedHashSet<>(Arrays.asList("张歆艺", "杨幂", "杨紫", "Jack", "杨幂"));
        System.out.println(set1);
        System.out.println(set1.getFirst());//
        System.out.println(set1.getLast());//
        SequencedSet<String> set2 = set1.reversed();
        System.out.println(set2);
        SequencedSet<String> treeSet = new TreeSet<>();
        treeSet.add("张歆艺");
        treeSet.add("杨幂");
        treeSet.add("杨紫");
        treeSet.add("Jack");
        System.out.println(treeSet);
        System.out.println(treeSet.getFirst());
        System.out.println(treeSet.getLast());
        System.out.println(treeSet);
        System.out.println(treeSet.reversed());

        //HashSet本身是无序的，没有实现SequencedSet接口，因此，不具备上述功能
        // SequencedSet<String> hashSet = new HashSet<>()'
    }
}
